﻿using System;

namespace DbMetadata
{
    /// <summary>
    /// Provides metadata information about a relation between two tables.
    /// </summary>
    [Serializable]
    public class DbRelationInfo
    {
        /// <summary>
        /// Points to the primary key of the primary table.
        /// </summary>
        /// <value></value>
        public DbPrimaryKeyInfo PrimaryKey { get; set; }

        /// <summary>
        /// The foreign key that is used to refer the primary table.
        /// </summary>
        /// <value></value>
        public DbForeignKeyInfo ForeignKey { get; set; }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (PrimaryKey != null && ForeignKey != null)
                return string.Format("{0} -> {1}", ForeignKey.Name, PrimaryKey.Name);
            return base.ToString();
        }
    }
}
